﻿<UserControl x:Class="MContracts.View.DisposalsRepositoryView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             xmlns:converters="clr-namespace:MContracts.Classes.Converters"
             xmlns:vm="clr-namespace:MContracts.ViewModel" DataContext="{Binding}">
    
    <UserControl.Resources>
        <converters:CurrencyConverter x:Key="CurrencyConverter1" />
        <converters:DateTimeToDateConverter x:Key="DateTimeToDateConverter" />
        <converters:DateTimeToShortDateConverter x:Key="DateTimeToShortDateConverter"/>
        <converters:ContractdocConverter x:Key="ContractdocConverter"/>
        <converters:ContractToVisibilityConverter x:Key="ContractToVisibilityConverter"/>


    </UserControl.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="32"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
            <TextBlock VerticalAlignment="Center" Margin="5, 0, 0, 0" x:Name="PropertyTextBlock" Text="{Binding Name}" FontSize="12" FontWeight="Bold"/>
            <Button ToolTip="Добавить распоряжение"  Command="{Binding NewDisposalCommand}" Width="30" Height="30">
                <Image Source="/MContracts;component/Resources/disposal-new.png"/>
            </Button>
            <Button ToolTip="Редактировать распоряжение" Command="{Binding EditDisposalCommand}" Width="30" Height="30">
                <Image Source="/MContracts;component/Resources/disposal-edit.png" />
            </Button>
            <Button ToolTip="Удалить распоряжение" Command="{Binding DeleteDisposalCommand}" Width="30" Height="30" >
                <Image Source="/MContracts;component/Resources/disposal-delete.png" />
            </Button>
        </StackPanel>

        <ScrollViewer Grid.Row="1">
            <StackPanel>
            <telerik:RadGridView ItemsSource="{Binding Disposals, Mode=OneWay}" 
                                 SelectedItem="{Binding SelectedDisposal}" 
                                 AutoGenerateColumns="False" 
                                 x:Name="DisposalsDataGrid" 
                                 SelectionMode="Extended"  
                                 SelectionUnit="FullRow"
                                 ShowColumnHeaders="True"
                                 ShowGroupPanel="False"
                                 ShowColumnFooters="False"
                                 IsReadOnly="True"
                                 RowIndicatorVisibility="Collapsed">

                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn Header="№ распоряжения" DataMemberBinding="{Binding Num}" Width="100" />
                        <telerik:GridViewDataColumn Header="Дата распоряжения" DataMemberBinding="{Binding Approveddate, Converter={StaticResource DateTimeToShortDateConverter}}" Width="Auto" />
                        <telerik:GridViewDataColumn Header="Договоры" DataMemberBinding="{Binding ContractdocNums}" Width="*" />
                    </telerik:RadGridView.Columns>


                </telerik:RadGridView>

        </StackPanel>
      </ScrollViewer>

    </Grid>
    
</UserControl>
